//
//  ZJMarqueeVIew.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/6/21.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJMarqueeVIew.h"
#import "SXHeadLine.h"

@interface ZJMarqueeVIew ()

/** 跑马灯视图 */
@property (nonatomic, strong) SXHeadLine *headLine;
@end

@implementation ZJMarqueeVIew

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.imageView];
        [self addSubview:self.headLine];
    }
    return self;
}

- (void)setHeadLine_messageArray:(NSArray *)messageArray{
    self.headLine.messageArray = messageArray;
    [self.headLine setScrollDuration:0.5 stayDuration:3];
    __weak typeof(self) weakSelf = self;
    [self.headLine changeTapMarqueeAction:^(NSInteger index) {
        if (weakSelf.delegate) {
            [weakSelf.delegate ZJMarqueeVIewDelegate_seleIndex:index];
        }
    }];
     [self.headLine start];
}



- (UIImageView *)imageView{
    if (_imageView == nil){
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(12 * [UIScreen zj_screenWScale], 5 * [UIScreen zj_screenHScale], self.height - 10 * [UIScreen zj_screenHScale], self.height - 10 * [UIScreen zj_screenHScale])];
        _imageView.contentMode = UIViewContentModeCenter;
        
    }
    return _imageView;

}

- (SXHeadLine *)headLine{
    if (_headLine == nil){
        _headLine = [[SXHeadLine alloc]initWithFrame:CGRectMake(self.imageView.right + 8 * [UIScreen zj_screenWScale], 0, self.width - 20 * [UIScreen zj_screenWScale] - self.imageView.right, self.height)];
        _headLine.textFont = [UIFont titleTextFont];
        _headLine.textColor = [UIColor textBlackColor];
        _headLine.bgColor = [UIColor clearColor];
    }
    return _headLine;
}

@end
